package vsvm.gui.controls;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JToggleButton;

import vsvm.gui.Environment;
import vsvm.gui.VSVMInternalFrame;

public class TaskBar extends JScrollPane{
	private static final long serialVersionUID = 100L;
	
	public static final int WINDOW_BAR_HEIGHT = 30;
	
	
	private JPanel backPanel = new JPanel();	
	private TaskBarButton lastSelected = null;	
		
	public TaskBar() {
		
		this.backPanel.setLayout(new FlowLayout(FlowLayout.LEFT));		
		this.setBorder(BorderFactory.createEtchedBorder());
		
		this.getViewport().add(backPanel);
		this.getViewport().setPreferredSize(new Dimension(200, TaskBarButton.BAR_BUTTON_HEIGHT + 10));		
	
		
	}
	
	public void addWindow(VSVMInternalFrame iFrame) {
		
		TaskBarButton button = new TaskBarButton(iFrame, this);
		iFrame.setTaskBarButton(button);							
		this.backPanel.add(button);	
		
	}
	
	public void removeWindow(VSVMInternalFrame iFrame) {
		
		this.backPanel.remove(iFrame.getTaskBarButton());
		this.lastSelected = null;
		this.revalidate();
        this.repaint();
	}
	
	public void setLastSelected(TaskBarButton button) {
		this.lastSelected = button;
	}
	
	public TaskBarButton getLastSelected() {
		return this.lastSelected;
	}
}
